// "This sample program is provided AS IS and may be used, executed, copied and modified without royalty payment by customer (a) for its own
// instruction and study, (b) in order to develop applications designed to run with an IBM WebSphere product, either for customer's own internal use
// or for redistribution by customer, as part of such an application, in customer's own products. "
//
// (C) COPYRIGHT International Business Machines Corp., 2005,2006
// All Rights Reserved * Licensed Materials - Property of IBM

package com;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.motorola.examples.GenericExecutor;
import com.motorola.examples.processor.Processor;



public class FactoryBenchmarkServlet extends HttpServlet implements Servlet {
	private static final long serialVersionUID = 1L;


	public FactoryBenchmarkServlet() {
		super();
	}


	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		if (!resp.isCommitted()) {
			resp.setHeader("Pragma", "No-cache");
			resp.setHeader("Cache-Control", "no-cache");
			resp.setDateHeader("Expires", 0);
			resp.setContentType("text/html");
		}

		PrintWriter pw = new PrintWriter(resp.getWriter(), true);
		
		try {
			pw.println("<html><head>");
			pw.println("<title></title>");
			pw.println("</head>");
			pw.println("<body>");
			pw.println("<h2>Asynchronous Beans WASThreadFactory Benchmark - Using java.util.concurrent</h2>");

			new GenericExecutor().execute(new Processor());
		} catch (Throwable e) {
			pw.println("<pre>");
			e.printStackTrace(pw);
			pw.println("</pre>");
		} finally {
			try {
				pw.write("</body></html>");
			} catch (Exception e) {
				System.out.println("Caught exception: " + e);
				e.printStackTrace(System.out);
			}
		}
	}



}
